package com.wly.datapool.playerpool;

import java.util.HashMap;

public class PlayerManager
{
	private HashMap<Integer, BasePlayer> playerList;
	
	static private PlayerManager _instance = null;
	
	private PlayerManager()
	{
		playerList = new HashMap<Integer, BasePlayer>();
	}
	
	static public PlayerManager getInstance()
	{
		if(_instance == null)
		{
			_instance = new PlayerManager();
		}
		
		return _instance;
	}
	
	public void addPlayer(BasePlayer player)
	{
		if(player == null)
		{
			return;
		}
		playerList.put(player.getPlayerId(), player);
	}
	
	public void removePlayer(int playerId)
	{
		playerList.remove(playerId);
	}
	
	public void removeAll()
	{
		playerList.clear();
	}
	
	public BasePlayer getPlayerById(int id)
	{
		return playerList.get(id);
	}
}
